#ifndef FileDialog_First
#define FileDialog_First
#ifdef __GNUG__
#pragma interface
#endif

#include "Dialog.h"

class TextField;
class TextItem;
class CollectionView;
class OrdCollection;
class Menu;
class PopupButton;
class ImageItem;
class TextItem;
class ActionButton;
class Scroller;
class Data;
class DataListView;

//---- FileDialog --------------------------------------------------------------

const int cMaxPathName= 400;

typedef bool (EvtHandler::*FilterFunc)(Data *d);

//---- id's

const int
	cIdName      = cIdFirstUser + 110,
	cIdList      = cIdFirstUser + 111,
	cIdUpdate    = cIdFirstUser + 112,
	cIdPath      = cIdFirstUser + 113,
	cIdComponent = cIdFirstUser + 120;

const int
	cPathBuf      =   200,
	cItemMinWidth =   250,
	cNumItems     =   7;

enum FileDialogFlags {
	eFDRead,
	eFDWrite,
	eFDImport
};

enum FileDialogParts {
	eFDTopPart,
	eFDListPart,
	eFDEditTitlePart,
	eFDEditPart,
	eFDActionPart
};

//---- FileDialog --------------------------------------------------------------

class FileDialog : public Dialog {
public:
	MetaDef(FileDialog);

	FileDialog(const char *title= "File Dialog");
	~FileDialog();

	int ShowInWindow(FileDialogFlags, Clipper*, EvtHandler *eh= 0,
															const char *msg= 0);
	const char *FileName();
	const char *GetInitDir();
	Data *GetFileData();
	Data *GetData();
	virtual bool WrongType();
	virtual bool ChangeDirectory();

protected:
	void InputKbd(Token &t);
	VObject *DoMakeControls();
	VObject *DoMakeActions();
	void DoSetup();
	void DoRestore();
	void DoSetDefaults();
	void Control(int id, int, void *v);
	virtual void UpdateList();
	virtual void UpdatePath();
	virtual bool OpenOrChangeDir();
	virtual Data *FilterData(Data *d);
	virtual VObject *MakePart(int which);

protected:
	TextField *eti;
	TextItem *title;
	char *initDir;
	FileDialogFlags flags;
	DataListView *gridview;
	OrdCollection *pathList;
	EvtHandler *doc;
	Data *fileData;
	ActionButton *openButton;
	PopupButton *pathPopup;
	FilterFunc filterfunc;
	Scroller *scroller;
	Data *current;
};

inline const char *FileDialog::GetInitDir()
	{ return initDir; }
inline Data *FileDialog::GetFileData()
	{ return fileData; }
inline Data *FileDialog::GetData()
	{ return fileData; }

#endif

